<?php
namespace app\common\model;




use think\Db;

class Emoticon extends Base
{
    public function getList($map = []){
        return $this->alias('b')
            ->join('emoticon_category c','c.cid = b.cid','LEFT')
            ->where($map)
            ->order('sort')
            ->field('b.*,c.cate_name')
            ->paginate('',false,['query'=>request()->param()]);
    }

    public function getEmoticon($map = [],$limit = 6)
    {
        return $this->where($map)->field('id,thumbnail,img')->order('sort')->limit($limit)->select();
    }

    public function getEmoticonList()
    {
        $rows = Db::name('emoticon_category')->where('status',1)->field('cid,img,cate_name')->cache(15)->select();

        $map['status'] = 1;

        foreach ($rows as $k => $v){
            $map['cid'] = $v['cid'];
            $rows[$k]['items'] = $this->where($map)->order('sort')->field('id,thumbnail,img,title')->cache(15)->select();
        }

        return $rows;

    }



}